import { request } from '@/utils/request';

export interface LoginData {
  username: string;
  password: string;
}

export function login(params: LoginData): Promise<string> {
  return request.post({ url: '/login', params });
}

export function logout() {
  return request.post({ url: '/logout' });
}

export function getUser() {
  return request.get({ url: '/user' });
}

export function getUserPage(params: any) {
  return request.get({
    url: '/user/page',
    params,
  });
}

export function addUser(data: any) {
  return request.post({ url: '/user', data });
}

export function updateUser(data: any) {
  return request.put({ url: '/user', data });
}
export function deleteUser(id: string) {
  return request.delete({ url: `/user/${id}` });
}

/**
 * 修改密码
 */
export function changePwd(id: string, password: string) {
  return request.put({ url: '/user/password', data: { id, password } });
}
